package com.shenfa.dao;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.shenfa.bean.NetServer;

/**
 * NetServer参数数据库操作类
 * 
 * @author yanglong
 *
 */
public class NetServerDao {

	@Autowired
	private SqlMapClient sqlMapClient;
	
	/**
	 * 根据对象条件查询NetServer参数列表
	 * @param 	NetServer参数对象
	 * @return	NetServer参数列表
	 */
	@SuppressWarnings("unchecked")
	public List<NetServer> queryList(NetServer t, int start, int limit){
		List<NetServer> list = null;
		try {
			list = sqlMapClient.queryForList("netserver_manager.getList", t, start, limit);
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}
		return list;
	}
	public int queryCount(NetServer t){
		int a;
		try {
			a =(Integer) sqlMapClient.queryForObject("netserver_manager.getCount", t);
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
		return a;
	}
	
	/**
	 * 添加NetServer参数
	 * @param t	NetServer参数对象
	 * @return	1成功，0失败
	 */
	public int add(NetServer t){
		try {
			sqlMapClient.insert("netserver_manager.add", t);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
	}
	
	/**
	 * 更新NetServer参数信息
	 * @param t	NetServer参数对象
	 * @return	1成功，0失败
	 */
	public int upd(NetServer t) {
		try {
			sqlMapClient.update("netserver_manager.upd", t);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
	}
	
	/**
	 * 删除NetServer参数信息
	 * @param t	NetServer参数对象
	 * @return	1成功，0失败
	 */
	public int del(NetServer t) {
		try {
			sqlMapClient.delete("netserver_manager.del", t);
			return 1;
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
	}
}
